

###########################
##Analyze uniform.prior.gamma.out
############################

load("uniform.prior.gamma.out.Rda")
I.vec <- sort(unique(uniform.prior.gamma.out$I))    ## number of voters
J.vec <- sort(unique(uniform.prior.gamma.out$J))   ## number of votes
## generate plots
pdf("ThetaCorrelationUniform.pdf", height = 8, width = 8)
par(mfrow=c(length(I.vec), length(J.vec)))

for (I in I.vec){
  for (J in J.vec){
    # theta.corr.plot.name<-paste("theta.corr.I", I, "J", J, sep=".")
    theta.corr.plot.name<-""
    
    xlab<-bquote(paste("Corr b/w Estimated ", theta, " & True ", theta, ", I=", .(I), ", J=", .(J), sep=""))
    temp <- uniform.prior.gamma.out[uniform.prior.gamma.out$I == I & uniform.prior.gamma.out$J == J, ]
    
    hist(temp$theta.corr,main = theta.corr.plot.name,xlab = xlab, breaks = seq(0.6,1,0.01), freq = FALSE)
    
  }
}
dev.off()

pdf("ThetaMSEUniform.pdf", height = 8, width = 8)

par(mfrow=c(length(I.vec), length(J.vec)))
for (I in I.vec){
  for (J in J.vec){
    # theta.corr.plot.name<-paste("theta.mse.I", I, "J", J, sep=".")
    theta.corr.plot.name<-""
    xlab<-bquote(paste("MSE of Estimated ", theta, ", I=", .(I), ", J=", .(J), sep=""))
    temp <- uniform.prior.gamma.out[uniform.prior.gamma.out$I == I & uniform.prior.gamma.out$J == J, ]
    
    hist(temp$theta.mse,main = theta.corr.plot.name,xlab = xlab, breaks = seq(0,0.5,0.01), freq = FALSE)
    
  }
}
dev.off()

pdf("GammaCorrelationUniform.pdf", height = 8, width = 8)

par(mfrow=c(length(I.vec), length(J.vec)))
for (I in I.vec){
  for (J in J.vec){
    # gamma.corr.plot.name<-paste("gamma.corr.I", I, "J", J, sep=".")
    gamma.corr.plot.name<-""
    xlab<-bquote(paste("Corr b/w Estimated ", gamma, " & True ", gamma, ", I=", .(I), ", J=", .(J), sep=""))
    temp <- uniform.prior.gamma.out[uniform.prior.gamma.out$I == I & uniform.prior.gamma.out$J == J, ]
    
    hist(temp$gamma.corr,main = gamma.corr.plot.name,xlab = xlab, breaks = seq(0.6,1,0.01), freq = FALSE)
    
  }
}
dev.off()

pdf("GammaMSEUniform.pdf", height = 8, width = 8)

par(mfrow=c(length(I.vec), length(J.vec)))
for (I in I.vec){
  for (J in J.vec){
   
    # gamma.corr.plot.name<-paste("gamma.mse.I", I, "J", J, sep=".")
    gamma.corr.plot.name<-""
    xlab<-bquote(paste("MSE of Estimated ", gamma, ", I=", .(I), ", J=", .(J), sep=""))
    temp <- uniform.prior.gamma.out[uniform.prior.gamma.out$I == I & uniform.prior.gamma.out$J == J, ]
    hist(temp$gamma.mse,main = gamma.corr.plot.name,xlab = xlab, breaks = seq(0, 0.5, 0.01), freq = FALSE)
  }
}
dev.off()

###########################
##Analyze DP.prior.gamma.out
############################

load("dp.prior.gamma.out.Rda")
I.vec <- sort(unique(dp.prior.gamma.out$I))    ## number of voters
J.vec <- sort(unique(dp.prior.gamma.out$J))   ## number of votes
## generate plots

pdf("ThetaCorrelationDP.pdf", height = 8, width = 8)
par(mfrow=c(length(I.vec), length(J.vec)))
for (I in I.vec){
  for (J in J.vec){
    # theta.corr.plot.name<-paste("theta.corr.I", I, "J", J, sep=".")
    theta.corr.plot.name<-""
    xlab<-bquote(paste("Corr b/w Estimated ", theta, " & True ", theta, ", I=", .(I), ", J=", .(J), sep=""))#paste("theta.corr.I", I, "J", J, sep=".")
    temp <- dp.prior.gamma.out[dp.prior.gamma.out$I == I & dp.prior.gamma.out$J == J, ]
    
    hist(temp$theta.corr,main = theta.corr.plot.name,xlab = xlab, breaks = seq(0.6,1,0.01), freq = FALSE)
    
  }
}
dev.off()

pdf("ThetaMSEDP.pdf", height = 8, width = 8)
par(mfrow=c(length(I.vec), length(J.vec)))
for (I in I.vec){
  for (J in J.vec){
    # theta.corr.plot.name<-paste("theta.mse.I", I, "J", J, sep=".")
    theta.corr.plot.name<-""
    xlab<-bquote(paste("MSE of Estimated ", theta, ", I=", .(I), ", J=", .(J), sep=""))#paste("theta.mse.I", I, "J", J, sep=".")
    temp <- dp.prior.gamma.out[dp.prior.gamma.out$I == I & dp.prior.gamma.out$J == J, ]
    
    hist(temp$theta.mse,main = theta.corr.plot.name,xlab = xlab, breaks = seq(0, 0.72, 0.01), freq = FALSE)
    
  }
}
dev.off()

pdf("GammaCorrelationDP.pdf", height = 8, width = 8)
par(mfrow=c(length(I.vec), length(J.vec)))
for (I in I.vec){
  for (J in J.vec){
    # gamma.corr.plot.name<-paste("gamma.corr.I", I, "J", J, sep=".")
    gamma.corr.plot.name<-""
    xlab<-bquote(paste("Corr b/w Estimated ", gamma, " & True ", gamma, ", I=", .(I), ", J=", .(J), sep=""))#paste("gamma.corr.I", I, "J", J, sep=".")
    temp <- dp.prior.gamma.out[dp.prior.gamma.out$I == I & dp.prior.gamma.out$J == J, ]
    
    hist(temp$gamma.corr,main = gamma.corr.plot.name,xlab = xlab, breaks = seq(0.3,1,0.01), freq = FALSE)
    
  }
}

dev.off()

pdf("GammaMSEDP.pdf", height = 8, width = 8)
par(mfrow=c(length(I.vec), length(J.vec)))
for (I in I.vec){
  for (J in J.vec){
    # gamma.corr.plot.name<-paste("gamma.mse.I", I, "J", J, sep=".")
    gamma.corr.plot.name<-""
    xlab<-bquote(paste("MSE of Estimated ", gamma, ", I=", .(I), ", J=", .(J), sep=""))#paste("gamma.mse.I", I, "J", J, sep=".")
    temp <- dp.prior.gamma.out[dp.prior.gamma.out$I == I & dp.prior.gamma.out$J == J, ]
    
    hist(temp$gamma.mse,main = gamma.corr.plot.name,xlab = xlab, breaks = seq(0,0.3,0.01), freq = FALSE)
    
  }
}
dev.off()

